<?php
include('../../include/functions.inc.php');

echo '<legend>Listado de Cursos</legend>';
?>
<table width="100%" cellpadding="0" cellspacing="1" class="table table-striped table-hover table-bordered">
        <tr>
            <td align="center"><input name="all" onclick="checkAll(this);"  type="checkbox" id="all" /></th>
            <td align="left"># CICLO</th>
            <td>CURSO</td>
            <td>
                SECCION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <select name="SECTION_ALL" id="SECTION_ALL" onchange="cambiarSeccionAll()">
                    <option value="A" selected="selected">A</option>
                    <option value="B">B</option>
                    <option value="C">C</option>
                    <option value="D">D</option>
                    <option value="E">E</option>
                    <option value="F">F</option>
                    <option value="G">G</option>
                    <option value="H">H</option>
                    <option value="I">I</option>
                    <option value="J">J</option>
                    <option value="K">K</option>
                    <option value="L">L</option>
                    <option value="M">M</option>
                    <option value="N">N</option>
                    <option value="O">O</option>
                </select>
            </th>
        </tr>
        <?php
        $f = date('y-d-m');
        $sql = "SELECT A.FK_COURSE,A.CYCLE,B.NAME FROM cllg_courses_pensum A,cllg_courses_catalog B ";
        $sql.="WHERE A.FK_COURSE=B.CODE AND FK_PENSUM=" . getParam("PENSUM");
        $sql.=" ORDER BY A.CYCLE ";
        $det = $db->queryToArray($sql);

        if (count($det) == 0) {
            ?>
            <tr>
                <td colspan="5" align="center" >No tiene configurados</td>
            </tr>
            <?php
        }
        else {
            $cycle = -1;
            foreach ($det as $c) {
                $row = array("CODE" => $c["FK_COURSE"], "NAME" => $c["NAME"]);
                $json_string = json_encode($row);
                if ($cycle != $c["CYCLE"]) {
                    $cycle = $c["CYCLE"];
                    ?>
                    <tr>
                        <td style="background-color: #c8c8c8" align="center"><input name="parent<?= $cycle ?>" onclick="checkChilds(this);checkPadre(<?= $cycle ?>);" type="checkbox" id="parent<?= $cycle ?>" /></td>
                        <td style="background-color: #c8c8c8" align="left">Ciclo&nbsp;<?= $cycle ?></td>
                        <td style="background-color: #c8c8c8" align="center">&nbsp;</td>
                        <td style="background-color: #c8c8c8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <select name="SECTION_ciclo_<?php print $cycle; ?>" id="SECTION_ciclo_<?php print $cycle; ?>" onchange="cambiarSeccion(<?php print $cycle; ?>);" disabled="disabled">
                                <option value="A" selected="selected">A</option>
                                <option value="B">B</option>
                                <option value="C">C</option>
                                <option value="D">D</option>
                                <option value="E">E</option>
                                <option value="F">F</option>
                                <option value="G">G</option>
                                <option value="H">H</option>
                                <option value="I">I</option>
                                <option value="J">J</option>
                                <option value="K">K</option>
                                <option value="L">L</option>
                                <option value="M">M</option>
                                <option value="N">N</option>
                                <option value="O">O</option>
                            </select>
                        </td>
                    </tr> 
                    <?php
                }
                ?> 
                <tr class="<?php #echo fmod($co, 2) == 0 ? 'data line0' : 'data line1'; ?>" >
                    <td align="center">
                        <input name="course_<?php echo $row['CODE']; ?>" onclick="viewChk(this);" type="checkbox"  class="parent<?= $cycle ?>" id="course_<?php echo $row['CODE']; ?>" alt="<?= $row['CODE'] ?>"/>
                    </td>
                    <td>&nbsp;</td>
                    <td><?php echo $row['NAME']; ?></td>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <select name="SECTION_course_<?php print $cycle; ?>_<?= $row['CODE'] ?>" id="SECTION_course_<?= $row['CODE'] ?>" onchange="updateCurso({id:<?= $row['CODE'] ?>,section:this.value})" disabled="disabled">
                            <option value="A" selected="selected">A</option>
                            <option value="B">B</option>
                            <option value="C">C</option>
                            <option value="D">D</option>
                            <option value="E">E</option>
                            <option value="F">F</option>
                            <option value="G">G</option>
                            <option value="H">H</option>
                            <option value="I">I</option>
                            <option value="J">J</option>
                            <option value="K">K</option>
                            <option value="L">L</option>
                            <option value="M">M</option>
                            <option value="N">N</option>
                            <option value="O">O</option>
                        </select>    
                    </td>
                </tr>
                <?php
            }
        }
        ?>
</table>